package com.xinzhang;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import com.asy.ui.base.Comment;
import com.tool.WebSeviceHelper;
import com.tool.tool;

import android.R.integer;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;

public class PicidoInit extends Activity {
	
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.picidoinit);
		final Handler handler = new Handler() {  
            public void handleMessage(Message message) {  	
					String res =message.obj.toString();
					JSONObject jsonObject;
					
					Intent intent=new Intent(PicidoInit.this,RecordTest.class);
					startActivity(intent);
					finish();
					/*
					try {
						jsonObject = new JSONObject(res);
						Intent intent=new Intent(PicidoInit.this,main.class);
						BaseApp myApp=(BaseApp)getApplication();
						myApp.setVersioncontent(jsonObject.getString("versioncontent"));
						myApp.setFilesize(jsonObject.getLong("FileSize"));
		                startActivity(intent);
		                finish();
					} catch (JSONException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
						Intent intent=new Intent(PicidoInit.this,main.class);
						BaseApp myApp=(BaseApp)getApplication();
						myApp.setVersioncontent("");
		                startActivity(intent);
		                finish();
					}
					*/
            }  
        };  
		Thread thread=new Thread(new Runnable()
			{
				public void run() {
					String res="";
					try {
						//res=HttpHelper.TcpIpLogin(bytes);
						Map<String, Object> map=new HashMap<String, Object>();
						map.put("version", tool.version);
						Object obj= WebSeviceHelper.getKSoapData("IsApkUpdate", map);
						res=obj.toString();
						Message message = handler.obtainMessage(0, res);  
	                    handler.sendMessage(message); 
					} catch (Exception e) {
						
						/*
						Intent intent=new Intent(PicidoInit.this,main.class);
						BaseApp myApp=(BaseApp)getApplication();
						myApp.setVersioncontent("");
		                startActivity(intent);
		                finish();*/
						
						Intent intent=new Intent(PicidoInit.this,RecordTest.class);
						startActivity(intent);
						finish();
						
					}
				}
			});
		thread.start();
	}

}
